﻿<%@ Page Language="C#"  MasterPageFile="~/templates/template.Master" AutoEventWireup="true" CodeBehind="producto.aspx.cs" Inherits="GesWork.maestros.producto" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


    <asp:content ID="df" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
      
          <asp:FormView ID="FormView1" runat="server" CellPadding="4" DataKeyNames="ID" DataSourceID="dsProductos" 
            ForeColor="#333333"  
            Width="690px" AllowPaging="True"  >
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#b3b3b3"  /><EditRowStyle  BackColor="#b3b3b3"  ForeColor="White" />
            <EditItemTemplate>
             <div class="recuadro">
                <!-- <b>ID:</b>-->
                <asp:Label ID="IDLabel1" runat="server" Text='<%# Eval("ID") %>' Visible="false"/>
                
                
                 <div class="separador"></div> 
                 <br />
                
                <b>Descripcion:</b>
                <asp:TextBox ID="DescriptionTextBox" runat="server" 
                    Text='<%# Bind("Description") %>' />
                <br />
               <b> Fecha de Entrada:</b>
                <asp:TextBox ID="RecDateTextBox" runat="server" Text='<%# Bind("RecDate") %>' />
                <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="RecDateTextBox" FirstDayOfWeek="Monday" Format="dd/MM/yyyy">
                </cc1:CalendarExtender>
                <br />
                
                <b>Categoria:</b>
                <asp:DropDownList ID="DropDownList1" 
                    runat="server" DataSourceID="dsCategoria" DataTextField="Description" 
                    DataValueField="ID" Text='<%# Bind("IdCategory") %>' >
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsCategoria" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [ProductCategory]">
                </asp:SqlDataSource>
               
               <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                <b>Precio Compra:</b>
                <asp:TextBox ID="SellPriceTextBox" runat="server" 
                    Text='<%# Bind("SellPrice") %>' />
                
                <br />
                <b>Precio Venta:</b>
                <asp:TextBox ID="SalePriceTextBox" runat="server" 
                    Text='<%# Bind("SalePrice") %>' />
                <br />
                <b>IVA:</b>
                <asp:TextBox ID="IVATextBox" runat="server" Text='<%# Bind("IVA") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                <b>Codigo de Barras:</b>
                <asp:TextBox ID="BarCodeTextBox" runat="server" Text='<%# Bind("BarCode") %>' />
                <br />
 <!--                <b>Imagen:</b>
                <asp:TextBox ID="IMG_ImageTextBox" runat="server" 
                    Text='<%# Bind("IMG_Image") %>' />
                
                <br /><br /> 
    -->             <div class="separador"></div> 
                 <br />
                 
                
<asp:ImageButton ID="UpdateButton" runat="server"  ImageUrl="~/images/btnGuardar.png"  CssClass="botones" CausesValidation="True" 
                    CommandName="Update" Text="Actualizar" />
               
<asp:ImageButton ID="UpdateCancelButton" runat="server"  ImageUrl="~/images/btnCancelar.png"  CssClass="botones" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
               </div>
            </EditItemTemplate>
            <InsertItemTemplate>
              <div class="recuadro"> 
                 <b>Descripcion:</b>
                <asp:TextBox ID="DescriptionTextBox" runat="server" 
                    Text='<%# Bind("Description") %>' />
                <br />
                <b> Fecha de Entrada:</b>
                <asp:TextBox ID="RecDateTextBox" runat="server" Text='<%# Bind("RecDate") %>' />
                <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="RecDateTextBox" FirstDayOfWeek="Monday" Format="dd/MM/yyyy">
                </cc1:CalendarExtender>
                <br />
                
                <b>Categoria:</b>
                <asp:DropDownList ID="DropDownList1" 
                    runat="server" DataSourceID="dsCategoria" DataTextField="Description" 
                    DataValueField="ID" Text='<%# Bind("IdCategory") %>' >
                </asp:DropDownList>
                <asp:SqlDataSource ID="dsCategoria" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
                    SelectCommand="SELECT [Description], [ID] FROM [ProductCategory]">
                </asp:SqlDataSource>
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                 <b>Precio Compra:</b>
                <asp:TextBox ID="SellPriceTextBox" runat="server" 
                    Text='<%# Bind("SellPrice") %>' />
                <br />
                 <b>Precio Venta:</b>
                <asp:TextBox ID="SalePriceTextBox" runat="server" 
                    Text='<%# Bind("SalePrice") %>' />
                <br />
                 <b>IVA:</b>
                <asp:TextBox ID="IVATextBox" runat="server" Text='<%# Bind("IVA") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                 <b>Codigo de Barras:</b>
                <asp:TextBox ID="BarCodeTextBox" runat="server" Text='<%# Bind("BarCode") %>' />
                <br />
  <!--                <b>Imagen:</b>
                <asp:TextBox ID="IMG_ImageTextBox" runat="server" 
                    Text='<%# Bind("IMG_Image") %>' />
                
                <br /><br /> 
     -->            <div class="separador"></div> 
                 <br />
                 
                
<asp:ImageButton ID="InsertButton" runat="server"  ImageUrl="~/images/btnGuardar.png"  CssClass="botones" CausesValidation="True" 
                    CommandName="Insert" Text="Insertar" />
               
<asp:ImageButton ID="InsertCancelButton" runat="server"  ImageUrl="~/images/btnCancelar.png"  CssClass="botones" 
                    CausesValidation="False" CommandName="Cancel" Text="Cancelar" />
                    
              </div>
            </InsertItemTemplate>
            <ItemTemplate>
            
              <div class="separador"></div> 
               <!--  <br /> 
                <b>ID:</b>-->
                <asp:Label ID="IDLabel" runat="server" Text='<%# Eval("ID") %>' Visible="false"/>
                
                 <br />
                <b>Descripcion:</b>
                <asp:Label ID="DescriptionLabel" runat="server" 
                    Text='<%# Bind("Description") %>' />
                <br />
                <b>Fecha de entrada:</b>
                <asp:Label ID="RecDateLabel" runat="server" Text='<%# Bind("RecDate") %>' />
                <br />
                <b>Categoria:</b>
                <asp:Label ID="IdCategoryLabel" runat="server" 
                    Text='<%# Bind("Categoria") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                 
                <b>Precio Compra:</b>
                <asp:Label ID="SellPriceLabel" runat="server" Text='<%# Bind("SellPrice") %>' />
                <br />
                <b>Precio Venta:</b>
                <asp:Label ID="SalePriceLabel" runat="server" Text='<%# Bind("SalePrice") %>' />
                <br />
                <b>IVA:
                <asp:Label ID="IVALabel" runat="server" Text='<%# Bind("IVA") %>' />
                
                <br /><br /> 
                 <div class="separador"></div> 
                 <br />
                
                <b>Codigo de barras:</b>
                <asp:Label ID="BarCodeLabel" runat="server" Text='<%# Bind("BarCode") %>' />
                <br />
<!--                 <b>Imagen:</b>
                
                <asp:Label ID="IMG_ImageLabel" runat="server" Text='<%# Bind("IMG_Image") %>' />
                 <br /><br /> 
   -->              <div class="separador"></div> 
                 <br />
                
                
                
            <asp:ImageButton ID="EditButton" runat="server"  ImageUrl="~/images/btnEditar.png"  CssClass="botones" CausesValidation="False" 
                    CommandName="Edit" Text="Editar" />
                    
                    
               
<asp:ImageButton ID="DeleteButton" runat="server"  ImageUrl="~/images/btnEliminar.png"  CssClass="botones" CausesValidation="False" 
                    CommandName="Delete" Text="Eliminar" />
                
<asp:ImageButton ID="NewButton" runat="server"  ImageUrl="~/images/btnNuevo.png"  CssClass="botones" CausesValidation="False" 
                    CommandName="New" Text="Nuevo" />
               
            </ItemTemplate>
        </asp:FormView>
      
  
    
        <asp:SqlDataSource ID="dsProductos" runat="server" 
            ConflictDetection="CompareAllValues" 
            ConnectionString="<%$ ConnectionStrings:gesworkConnectionString %>" 
            DeleteCommand="DELETE FROM [Product] WHERE [ID] = @original_ID " 
            InsertCommand="INSERT INTO [Product] ( [Description], [RecDate], [IdCategory], [SellPrice], [SalePrice], [IVA], [BarCode], [IMG_Image]) VALUES ( @Description, @RecDate, @IdCategory, @SellPrice, @SalePrice, @IVA, @BarCode, @IMG_Image)" 
            OldValuesParameterFormatString="original_{0}" 
            SelectCommand="SELECT Product.ID, Product.Description, RecDate, IdCategory, ProductCategory.description  AS Categoria, SellPrice, SalePrice, IVA, BarCode, Product.IMG_Image FROM Product, ProductCategory WHERE ProductCategory.id=Product.idcategory AND Product.ID =  @ID" 
            UpdateCommand="UPDATE [Product] SET [Description] = @Description, [RecDate] = @RecDate, [IdCategory] = @IdCategory, [SellPrice] = @SellPrice, [SalePrice] = @SalePrice, [IVA] = @IVA, [BarCode] = @BarCode, [IMG_Image] = @IMG_Image WHERE [ID] = @original_ID AND [Description] = @original_Description AND (([RecDate] = @original_RecDate) OR ([RecDate] IS NULL AND @original_RecDate IS NULL)) AND [IdCategory] = @original_IdCategory AND (([SellPrice] = @original_SellPrice) OR ([SellPrice] IS NULL AND @original_SellPrice IS NULL)) AND [SalePrice] = @original_SalePrice AND (([IVA] = @original_IVA) OR ([IVA] IS NULL AND @original_IVA IS NULL)) AND (([BarCode] = @original_BarCode) OR ([BarCode] IS NULL AND @original_BarCode IS NULL)) AND (([IMG_Image] = @original_IMG_Image) OR ([IMG_Image] IS NULL AND @original_IMG_Image IS NULL))">
            <SelectParameters>
                <asp:QueryStringParameter Name="ID" QueryStringField="id" Type="String" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_ID" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="RecDate"  Type="String"/>
                <asp:Parameter Name="IdCategory" Type="String" />
                <asp:Parameter Name="SellPrice" Type="Decimal" />
                <asp:Parameter Name="SalePrice" Type="Decimal" />
                <asp:Parameter Name="IVA" Type="Decimal" />
                <asp:Parameter Name="BarCode" Type="String" />
                <asp:Parameter Name="IMG_Image" Type="String" />
                <asp:Parameter Name="original_ID" Type="String" />
                <asp:Parameter Name="original_Description" Type="String" />
                <asp:Parameter Name="original_RecDate" Type="String"  />
                <asp:Parameter Name="original_IdCategory" Type="String" />
                <asp:Parameter Name="original_SellPrice" Type="Decimal" />
                <asp:Parameter Name="original_SalePrice" Type="Decimal" />
                <asp:Parameter Name="original_IVA" Type="Decimal" />
                <asp:Parameter Name="original_BarCode" Type="String" />
                <asp:Parameter Name="original_IMG_Image" Type="String" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="Description" Type="String" />
                <asp:Parameter Name="RecDate"  Type="String"/>
                <asp:Parameter Name="IdCategory" Type="String" />
                <asp:Parameter Name="SellPrice" Type="Decimal" />
                <asp:Parameter Name="SalePrice" Type="Decimal" />
                <asp:Parameter Name="IVA" Type="Decimal" />
                <asp:Parameter Name="BarCode" Type="String" />
                <asp:Parameter Name="IMG_Image" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>
      
  
    
    </asp:content>

